class Trie:
    def __init__(self):
        self.tag = 0
        self.next = {}

    def insert(self, s: str):
        """
        在Trie树中插入一个字符串s
        """
        tp = self
        for c in s:
            if not c in tp.next:
                tp.next[c] = Trie()
            tp = tp.next[c]
        tp.tag += 1

    def count(self, s: str):
        """
        在Trie树中查找s出现的次数
        """
        tp = self
        for c in s:
            if not c in tp.next:
                return 0
            tp = tp.next[c]
        return tp.tag
